﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace ZF.BLL.UserControls
{
    public class CheckBoxList:System.Web.UI.WebControls.CheckBoxList
    {
        public CheckBoxList()
            : base()
        {
            this.DataValueField = "Key";
            this.DataTextField = "Text";
        }
        public string[] SelectedValues
        {
            get
            {
                List<string> result = new List<string>();
                foreach (ListItem item in this.Items)
                {
                    if (item.Selected)
                    {
                        result.Add(item.Value);
                    }
                }
                return result.ToArray();
            }
            set
            {
                foreach (ListItem item in this.Items)
                {
                    item.Selected = value.Contains(item.Value);
                }
            }
        }
    }
}
